﻿@using StackExchange.DataExplorer
@model IEnumerable<StackExchange.DataExplorer.Models.OpenIdWhiteList>
@{this.SetPageTitle("Stack Exchange Data Explorer Administration - Stack Exchange Data Explorer");}
<table>
    <thead>
        <tr>
            <th>Url</th>
            <th>Approved?</th>
        </tr>
    </thead>
    @foreach (var entry in Model)
    {
        <tr>
            <td>@entry.OpenId</td>
            <td class="approved">@entry.Approved</td>
            <td>@entry.CreationDate</td>
            <td>@Html.Raw(entry.Approved ? "" : "<a href='/admin/whitelist/approve/" + entry.Id + "' class='approve'>approved</a>")</td>
            <td><a href="/admin/whitelist/remove/@(entry.Id)" class="remove">remove</a></td>
        </tr>
    }
</table>
<script type="text/javascript">
    $(document).ready(function () {
        $("a.approve").click(function () {
            var href = $(this);
            href.hide();
            $.post(this.href, null, function () {
                href.parent().parent().find('.approved').text('True');
            });
            return false;
        });

        $("a.remove").click(function () {
            var href = $(this);
            href.hide();
            $.post(this.href, null, function () {
                href.parent().parent().hide();
            });
            return false;
        });
    });
</script>
